using MediPlatform.Write.Api.Extensions;

namespace MediPlatform.Write.Api
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);

            // 使用扩展方法添加所有服务
            builder.Services.AddAllServices(builder.Configuration);

            // 添加控制器
            builder.Services.AddControllers();
            builder.Services.AddEndpointsApiExplorer();

            var app = builder.Build();

            // 配置HTTP请求管道
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "智慧医疗平台 Write API v1");
                    c.RoutePrefix = "swagger"; // 设置Swagger UI为/swagger路径
                });
            }

            // 使用CORS
            app.UseCors("AllowAll");

            // 注释掉认证和授权，写服务不需要JWT验证
            // app.UseAuthentication();
            // app.UseAuthorization();

            app.MapControllers();

            await app.RunAsync();
        }
    }
}
